package com.jnzc.ocr.serv.shop.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.jnzc.ocr.common.utils.ArrayHandleUtils;
import com.jnzc.ocr.dependencies.serv.mybatis.MybatisServiceImpl;
import com.jnzc.ocr.serv.shop.entity.ShopOrderSaleDetail;
import com.jnzc.ocr.serv.shop.filter.ShopOrderSaleDetailFilter;
import com.jnzc.ocr.serv.shop.mapper.ShopOrderSaleDetailMapper;
import com.jnzc.ocr.serv.shop.service.ShopOrderSaleDetailService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author zhangcm
 * @version 1.0, 2017-10-06
 */
@Service
public class ShopOrderSaleDetailServiceImpl extends MybatisServiceImpl<ShopOrderSaleDetailMapper, ShopOrderSaleDetail, ShopOrderSaleDetailFilter> implements ShopOrderSaleDetailService {

    @Override
    protected void fillEntityWrapper(EntityWrapper<ShopOrderSaleDetail> ew, ShopOrderSaleDetailFilter filter) {
        ShopOrderSaleDetail entity = new ShopOrderSaleDetail();
        entity.setOrderId(filter.getOrderId());
        ew.setEntity(entity);
    }

    @Override
    public List<ShopOrderSaleDetail> list(Long orderId) {
        ShopOrderSaleDetailFilter filter = new ShopOrderSaleDetailFilter();
        filter.setOrderId(orderId);
        return super.list(filter);
    }

    @Override
    public Map<Long, ShopOrderSaleDetail> listSkuMap(Long orderId) {
        List<ShopOrderSaleDetail> list = list(orderId);
        return ArrayHandleUtils.parseMap(list, "skuId");
    }
}
